//    Copyright (C) Kherty.  All rights reserved.
using System.Diagnostics;
using System.Diagnostics.Contracts;

namespace OpenLS.Spreadsheet.Parsing
{
    class SpaceProcessor : TokenCreator
    {
        public override Token Match(Lexer l)
        {
            Len = 0;
            bool stop = false;
            do
            {
                char c = l[l.Position + Len];
                switch (c)
                {
                    case ' ':
                    case '\t': l.Column++; break;
                    case '\n': l.Column = 0; l.Line++; break;
                    case '\r': break;
                    default: stop = true; break;
                }
                Len++;
            }
            while (!stop);
            Len--;
            Contract.Assert(Len > 0);
            return null;
        }
        public override char[] FirstChars()
        {
            return new char[] { ' ', '\n', '\t', '\r' };
        }
        public override int MatchSize()
        {
            return Len;
        }
        int Len;
    }
}